<?php
// +----------------------------------------------------------------------+
// | Author:  Evgeny Leontev <eleontev@gmail.com>                         |
// | Copyright (c) 2005 Evgeny Leontev                                    |
// +----------------------------------------------------------------------+
// | This source file is free software; you can redistribute it and/or    |
// | modify it under the terms of the GNU Lesser General Public           |
// | License as published by the Free Software Foundation; either         |
// | version 2.1 of the License, or (at your option) any later version.   |
// |                                                                      |
// | This source file is distributed in the hope that it will be useful,  |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
// | Lesser General Public License for more details.                      |
// +----------------------------------------------------------------------+

require_once APP_MODULE_DIR . 'setting/inc/SettingModel.php';


class AppMailModel extends BaseModel
{

	var $tbl_pref_custom = '';
	var $tables = array('letter_template', 'user');

	
	function getTemplate($id) {
		$sql = "SELECT body FROM {$this->tbl->letter_template} WHERE id = '$id' OR letter_key = '$id'";
		$result =& $this->db->Execute($sql) or die(db_error($sql));
		return $result->Fields('body');		
	}
	
	
	function getTemplateVars($id) {
		$sql = "SELECT * FROM {$this->tbl->letter_template} WHERE id = '$id' OR letter_key = '$id'";
		$result =& $this->db->Execute($sql) or die(db_error($sql));
		return $result->FetchRow();		
	}
	
	
	function &getSettings() {
		$s = &new SettingModel();
		$s->setModuleId('email_setting');
		return $s->getSettings();	
	}
}
?>